package mmc.objects;

import static org.lwjgl.opengl.GL11.glPopMatrix;
import static org.lwjgl.opengl.GL11.glPushMatrix;

import org.lwjgl.opengl.GL11;

import mmc.EngineObject;
import mmc.server.Server;

@SuppressWarnings("serial")
public class Consecration extends EngineObject {

	private transient float tick = 1f;
	private transient float duration = 10f;
	private float radius = 5f;
	
	public Consecration(float x, float y, float z) {
		super(x, y, z);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void render(EngineObject observer) {
		// TODO Auto-generated method stub
		glPushMatrix();
		GL11.glTranslatef(x, y+0.001f, z);  
		radialGradientCircle(new float[]{0,0, 0, 0.5f}, new float[]{0, 0,0, 0.5f}, 30, radius);
		glPopMatrix(); 
	}

	
	@Override
	public void update(float dt) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void update(Server server, float dt) {
		// TODO Auto-generated method stub
		tick -= dt;
		
		if(tick <= 0){
			for(EngineObject x : server.getScene().objects.values()){
				if(x instanceof Mob){
					if(this.inRange(x, radius)){
						x.takeDamage(5);
					}
				}
			}			
			tick = 1f;
		}
		
		duration -= dt;		
		if(duration <= 0){
			server.getScene().removeObject(this);
		}
	}

}
